            var websocket;
            function setupWebSocket() { 
                //alert("setupWebSocket()");
                websocket = new WebSocket(websocketURL);
                websocket.onmessage = function(evt) { 
                    //alert("websocket.onmessage.data = "+evt.data); 
                    var json = eval("("+evt.data+")");
                    //alert("json.command="+json.command);
                    //alert("dish" == json.command);
                    if("orderList" == json.command){//获取orderList用于编辑或提交前的确认
                        //alert("orderList response message.data = " + evt.data);
                        window.location.href = "callObjC://orderList?courses="+json.courses;
                    } else if("receive" == json.command){
                        //alert("dish response message.data = " + evt.data);
                        window.location.href = "callObjC://receive?courseId="+json.courseId;
                    } else if("message" == json.command){
                        //alert("dish response message.data = " + evt.data);
                        var varHref = "callObjC://message?message="+json.message;
                        //alert("url = "+varHref);
                        window.location.href = varHref;
                    } else if("removeReceive" == json.command){
                        //alert("dish response message.data = " + evt.data);
                        window.location.href = "callObjC://removeReceive?courseId="+json.courseId;
                    }else{
                        //alert("Unkown message from server. message.data = " + evt.data);
                    }                
                }; 

                websocket.onclose = function() { 
                    alert("websocket.onclose()"); 
                }; 

                websocket.onopen = function() {
                    var commandTemp = "openTable";
                    //alert("websocket.onopen() runningMode");
                    if("Client" == mode){//这个参数，在加载页面时，从客户端传给服务器
                        commandTemp = "join";
                    }
                    //alert("websocket.onopen() commandTemp = "+commandTemp);
                    var msg = JSON.stringify({
                        command: commandTemp,
                        menuId: menuId,
                        menuName: menuName,
                        tableName: tableName,
                        opener: tableOpener
                    });
                    websocket.send(msg); 
                }; 
            } 
            
            function orderDish(paramCourseId, paramCoursePrice){
                //alert("orderDish() is called!");
                //alert("websocket = "+websocket);
                websocket.send(JSON.stringify({
                    command: "dish",
                    tableName: tableName,
                    menuId: menuId,
                    courseId: paramCourseId,
                    price: paramCoursePrice
                })); 
                //alert("websocket sended");
            }
            
            function removeCourse(paramServersideId){
                //alert("orderDish() is called!");
                //alert("websocket = "+websocket);
                websocket.send(JSON.stringify({
                    command: "removeCourse",
                    orderedCourseId: paramServersideId
                })); 
                //alert("websocket sended");
            }
            
            function orderList(){
                websocket.send(JSON.stringify({
                    command: "orderList"
                })); 
            }
            
            function finishOrder(){
                websocket.send(JSON.stringify({
                    command: "finishOrder"
                })); 
            }        
